全部文档

7.1MQTT和OPC UA物模型

为MQTT、OPC UA协议产品提供协议相关属性的增删改查功能。

7.1.1根据功能ID查询功能

功能描述:根据产品ID和该产品下的功能ID查询产品功能, 返回产品功能的详细信息。

GET  /api/v1/products/{productId}/properties/{id}

Path:

Name Type Description Required
id string 功能ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus功能属性ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": {
        "id": 9426,
        "userId": null,
        "productId": 103609,
        "name": "test",
        "nodeName": "",
        "identifier": "test",
        "accessMode": 2,
        "type": 5,
        "unit": "",
        "minimum": 1,
        "maximum": 10,
        "minString": null,
        "maxString": null,
        "special": {
            "length": null,
            "step": 5.0,
            "enumArray": null
        },
        "required": false,
        "kind": 2,
        "class": 1
    },
    "success": true,
    "code": 0,
    "msg": null
}

7.1.2根据产品ID查询所有功能

功能描述:查询指定产品下的功能,返回产品功能列表。

GET  /api/v1/products/{productId}/properties

Path:

Name Type Description Required
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus功能属性ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": [
        {
            "id": 9426,
            "userId": null,
            "productId": 103609,
            "name": "test",
            "nodeName": "",
            "identifier": "test",
            "accessMode": 2,
            "type": 5,
            "unit": "",
            "minimum": 1,
            "maximum": 10,
            "minString": "1",
            "maxString": "10",
            "special": {
                "length": null,
                "step": 5.0,
                "enumArray": null
            },
            "required": false,
            "kind": 2,
            "class": 1
        }
    ],
    "success": true,
    "code": 0,
    "msg": null
}

7.1.3新增物模型草稿

功能描述:指定产品,为该产品添加物模型草稿,用于读写产品属性值。返回物模型草稿的ID。

POST  /api/v1/products/{productId}/properties/draft

Path:

Name Type Description Required
productId string 产品ID Yes

Body:

Name Type Description Required
name string 功能名称 Yes
identifier string 属性名称(该产品下唯一) Yes
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W) Yes
type int 数据类型,具体值参考公共能力type类型码表。 Yes
unit string 属性单位 Yes
minimum number 参数最小值(数值类型特有) No,type为数值类型必填
maximum number 参数最大值(数值类型特有) No,type为数值类型必填
nodeName String 节点名称 No(当为OPC UA时必传)
special struct 对部分数据类型的补充说明 No(string/bytes/float32/float64/boolean/enum时必传)

参数type类型码表:

string boolean int32 int64 float32 float64 date enum
1 2 3 4 5 6 8 9

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
        "identifier":"temperature",
        "type":1,
        "name":"temperature",
        "accessMode":2,
        "special":{
            "length":2048
         }
}

cURL example:

curl --location --request POST '{{address}}/api/v1/products/{productId}/properties/draft?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                    "identifier":"temperature",
                    "type":1,
                    "name":"temperature",
                    "accessMode":2,
                    "special":{
                        "length":2048
                     }
            }'

Response body:

Name Type Description
id int Modbus物模型草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId number 产品ID
userId string 用户ID
nodeName String 节点名称

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 23,
    "name": "temperature",
    "identifier": "temperature",
    "accessMode": 2,
    "type": 1,
    "unit": null,
    "minimum": null,
    "maximum": null,
    "minString": null,
    "maxString": null,
    "productId": 100152,
    "userId": "a881f626c8ec42ceb4c597a3ce7f0bbe",
    "nodeName": null
  }
}

7.1.4删除物模型草稿

功能描述:删除指定产品下的某一物模型草稿。

DELETE  /api/v1/products/{productId}/properties/draft/{id}

Path:

Name Type Description Required
id string 物模型草稿ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request DELETE '{{address}}/api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

7.1.5更新物模型草稿

功能描述:更新指定产品下的某一物模型草稿。

PUT  /api/v1/products/{productId}/properties/draft/{id}

Body:

Name Type Description Required
name string 功能名称 No
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W) No
unit string 属性单位 No
minimum number 参数最小值(Integer,Long, Float, Double) No
maximum number 参数最大值(Integer,Long, Float, Double) No
special struct 对部分数据类型的补充说明 No

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
        "identifier":"temperature",
        "type":1,
        "name":"temperature",
        "accessMode":2,
        "special":{
            "length":2048
         }
}

cURL example:

curl --location --request PUT '{{address}}/api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                    "identifier":"temperature",
                    "type":1,
                    "name":"temperature",
                    "accessMode":2,
                    "special":{
                        "length":2048
                     }
            }'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

7.1.6根据物模型草稿ID查询详情

功能描述:根据产品ID和该产品下的物模型草稿ID查询详细信息。

GET  /api/v1/products/{productId}/properties/draft/{id}

Path:

Name Type Description Required
id string 物模型草稿ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus功能属性ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": {
        "id": 9426,
        "userId": null,
        "productId": 103609,
        "name": "test",
        "nodeName": "",
        "identifier": "test",
        "accessMode": 2,
        "type": 5,
        "unit": "",
        "minimum": 1,
        "maximum": 10,
        "minString": null,
        "maxString": null,
        "special": {
            "length": null,
            "step": 5.0,
            "enumArray": null
        },
        "required": false,
        "kind": 2,
        "class": 1
    },
    "success": true,
    "code": 0,
    "msg": null
}

7.1.7根据产品ID查询所有物模型草稿

功能描述:查询指定产品下的功能,返回产品物模型草稿列表。

GET  /api/v1/products/{productId}/properties/draft

Path:

Name Type Description Required
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/draft?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus物模型草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": [
        {
            "id": 9426,
            "userId": null,
            "productId": 103609,
            "name": "test",
            "nodeName": "",
            "identifier": "test",
            "accessMode": 2,
            "type": 5,
            "unit": "",
            "minimum": 1,
            "maximum": 10,
            "minString": "1",
            "maxString": "10",
            "special": {
                "length": null,
                "step": 5.0,
                "enumArray": null
            },
            "required": false,
            "kind": 2,
            "class": 1
        }
    ],
    "success": true,
    "code": 0,
    "msg": null
}

7.1.8发布物模板草稿

功能描述:发布指定产品下的所有物模板草稿。

POST  /api/v1/products/{productId}/properties/draft/publish

Path:

Name Type Description
productId int 产品ID

cURL example:

curl --location --request POST '{{address}} /api/v1/products/{productId}/properties/draft/publish?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": null
}

results matching ""

    No results matching ""